/* -*-c++-*- */
/* osgEarth - Geospatial SDK for OpenSceneGraph
 * Copyright 2020 Pelican Mapping
 * http://osgearth.org
 *
 * osgEarth is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
 */

#ifndef OSGEARTH_METADATANODE_H
#define OSGEARTH_METADATANODE_H 1

#include <osgEarth/Common>
#include <osgEarth/Feature>
#include <osgEarth/ObjectIndex>
#include <osg/Group>
#include <osg/Array>
#include <osg/BufferIndexBinding>

namespace osgEarth
{
    class OSGEARTH_EXPORT MetadataNode : public osg::Group
    {
    public:
        MetadataNode();

        MetadataNode(const MetadataNode& rhs, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY);

        META_Node(osgEarth, MetadataNode);

        virtual ~MetadataNode();

        virtual ObjectID add(Feature* feature, bool visible = true);

        virtual void tagDrawable(osg::Drawable* drawable, ObjectID id) const;

        virtual void tagNode(osg::Node* node, ObjectID id) const;

        virtual void finalize();

        virtual unsigned int getNumFeatures() const;

        virtual bool getVisible(unsigned int index) const;

        virtual void setVisible(unsigned int index, bool value);

        virtual ObjectID getObjectID(unsigned index) const;

        virtual const Feature* getFeature(unsigned int index) const;

        virtual Feature* getFeature(unsigned int index);

        virtual int getIndexFromObjectID(ObjectID id) const;

    protected:
        virtual void init();

        std::vector< osg::ref_ptr< Feature > > _features;
        osg::ref_ptr< osg::Vec2uiArray > _instances;
    };

} // namespace osgEarth

#endif // OSGEARTH_METADATANODE_H
